<template>
    <div>
        <div>用户名：<el-input  v-model="data.loginName" style="width:200px;" /></div>
        <div>密码：<el-input v-model="data.password" type="password" style="width:200px;" /></div>
        <div><el-button @click="eventLogin">登录</el-button></div>
    </div>
</template>

<script>
export default {
    data(){
        return{
            data : {
                "loginName": undefined,
                "password": undefined
            }
        }
    },
    methods: {
        eventLogin() {
            let url = this.$baseUrl + '/member/login'
            this.$http.post(url, this.data).then(res => {
                console.log(res)
                if (res.data.code == 200) {
                    this.$message.info(res.data.message)
                    
                    //缓存用户信息
                    localStorage.setItem("2011A_member_info",JSON.stringify(res.data.data))

                    //跳转到商品列表
                    this.$router.push('/product/list')
                }else{
                    this.$message.error(res.data.message)
                }
            })
        }
    }
}
</script>